const Path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
	mode: 'production',//'development production',
	//devtool: 'source-map',//追踪错误源码
	entry: {
		'lyj.Msg': { import: './src/index.js' },
	},
	output: {
		path: Path.resolve(__dirname, 'dist'),
		filename: '[name].js'
	},
	plugins: [
		new CleanWebpackPlugin({ cleanStaleWebpackAssets: false }),
		new HtmlWebpackPlugin({ template: './src/index.html', }),
		new MiniCssExtractPlugin({ filename: '[name].css' })
	],
	module: {
		rules: [
			{
				test: /\.scss$/i,
				use: [
					{ loader: MiniCssExtractPlugin.loader },
					{
						loader: 'css-loader',
					},
					'sass-loader',
				]
			},
		]
	}
}